<?php
/**
 * Klasse zur Ermittlung von ungewollten Email-Adressen
 * 
 * @author		Joachim Ruf
 * @copyright	Copyright (c) 2003-2010 Loresoft Software (http://www.loresoft.de)
 * @license		http://yapary.loresoft.de/lizenzbedingungen     New BSD License
 * 
 * */

Class Yapary_Email_EmailBlacklist
{
    private $xml = NULL;
    private $oXmlLoader = NULL;
        
    
    function __construct (Yapary_XmlLoader $_cXmlLoader, $xmlFilePath)
    {
        $this->oXmlLoader = $_cXmlLoader;
        $this->xml = $this->oXmlLoader->getFromFile($xmlFilePath);
    }


    /**
     * Prueft ob die Email-Adresse aus einer in der Blacklist definierten Domain stammt
     * @param string $email	: zu pruefende Email-Adresse
     * @return bool
     * */
    public function exists ($email)
    {
        if ($this->xml == NULL) {
            throw new Exception('keine Email Blacklist geladen');
        }
        
        if (count($this->xml)) {
            foreach ($this->xml as $key => $val) {
                if (strpos($email, '@'.$val) !== false) {
                    return true;
                }
            }
        }
        
        return false;
    }

    
    public function getList ()
    {
        $arrResult = array();

        if (count($this->xml)) {
            foreach ($this->xml as $key => $val) {
                $arrResult[] = $val;
            }
        }
        
        return $arrResult;
    }
    
}

?>